﻿//
// Copyright (c) 2019-2023 BPer
//
#ifndef BPERPLAYER_INCLUDE_BPERAVSYN_H_
#define BPERPLAYER_INCLUDE_BPERAVSYN_H_
#include <bperutil/sys/BPerTime.h>

#include <bperutil/BPerAvType.h>
#include <bperutil/buffer/BPerAudioPlayBuffer.h>
#include <bperavutil/audio/BPerAudioMix.h>
#include <bperutil/buffer/BPerVideoBuffer.h>


enum BPerSynType{
	BPER_SYNC_AUDIO_MASTER, /* default choice */
	BPER_SYNC_VIDEO_MASTER,
	BPER_SYNC_EXTERNAL_CLOCK, /* synchronize to an external clock */
};
#define BPer_Max_Audio_Intervaltime 25
#define BPer_Max_Video_Intervaltime 35
#define BPer_Video_Base_Update_Interval 600000//10*60*1000  //10m
#define BPer_Audio_Base_Update_Interval 5000//10*60*1000  //10m
#define BPer_Video_Cache_time 35
#define BPer_Audio_Cache_time 5



typedef struct{
	void* session;
    uint8_t* (*getVideoRef)(void* session,BPerFrame* pframe);
    uint8_t* (*getAudioRef)(void* session,BPerFrame* audioFrame);
    void (*setInAudioBuffer)(void* session,BPerAudioPlayBuffer *paudioList);
    void (*setInVideoBuffer)(void* session,BPerVideoBuffer *pbuf);
    void (*setAudioClock)(void* session,int32_t paudioclock);
    void (*setVideoClock)(void* session,int32_t pvideoclock);
    void (*setUid)(void* session,int32_t uid);
    int32_t (*getUid)(void* session);
    int32_t (*getAudioSize)(void* session);
    int32_t (*getVideoSize)(void* session);
    void (*resetVideoClock)(void* psession);
    void (*resetAudioClock)(void* psession);
    int32_t (*width)(void* psession);
    int32_t (*height)(void* psession);
}BPerSynBuffer;



void bPer_create_synBuffer(BPerSynBuffer* syn);
void bPer_destroy_synBuffer(BPerSynBuffer* syn);

#endif /* BPERPLAYER_INCLUDE_BPERAVSYN_H_ */
